<template>
    <bs-dialog title="上传当前系统日志文件" :visible="visible" @update:visible="updateVisible" size="mini" @closed="doCloseEdit" @opened="init">
        <template slot="main">
            <el-form ref="syslogForm" :inline="true" :model="editorForm" :rules="editorFormRules" label-width="80px" size="small" :show-message="false" :hide-required-asterisk="true" :status-icon="false">
                <el-form-item :label="$t('开始时间')">
                    <el-date-picker v-model="editorForm.startDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd"></el-date-picker>
                </el-form-item>
                <el-form-item :label="$t('结束时间')">
                    <el-date-picker v-model="editorForm.endDate" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd"></el-date-picker>
                </el-form-item>
            </el-form>
        </template>
        <template slot="footer">
            <el-button type="primary" size="small" @click.native="handleSendCommand">发送命令</el-button>
        </template>
    </bs-dialog>
</template>

<script>
    export default {
        data() {
            return {
                editor: false,
                editorForm: {
                    startDate: '',
                    endDate: ''
                },
                editorFormRules: {}
            }
        },
        props: {
            visible: {
                type: Boolean,
                default: false
            }
        },
        methods: {
            init() {
                this.editorForm.startDate = this.$moment().format('YYYY-MM-DD')
                this.editorForm.endDate = this.$moment().format('YYYY-MM-DD')
            },
            doCloseEdit() {
                this.updateVisible(false)
            },
            updateVisible(v) {
                this.$emit('update:visible', v)
            },
            handleSendCommand() {
                this.$emit('send', this.editorForm)
                this.$refs['syslogForm'].resetFields();
            }
        }
    }
</script>

<style lang="scss" scoped>
  ::v-deep .el-dialog {
    width: 460px !important;
    height: 160px !important;
  }
  ::v-deep .el-dialog__body {
    padding-top: 15px !important;
  }
</style>